#include <iostream>
using namespace std;
typedef long long LL;

//二维差分
//https://www.nowcoder.com/practice/50e1a93989df42efb0b1dec386fb4ccc?tpId=230&tqId=38963&ru=/exam/oj

const int N = 1e3 + 10;
LL dis[N][N];

void insert(int x1, int y1, int x2, int y2,  LL k)
{
    dis[x1][y1] += k;
    dis[x1][y2 + 1] -= k;
    dis[x2 + 1][y1] -= k;
    dis[x2 + 1][y2 + 1] += k;
}  

int main()
{
    int n,m,q; cin >> n >> m >> q;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
        {
            LL tmp;
            cin >> tmp; 
            insert(i,j,i,j,tmp);
        }

    while(q--)
    {
        LL x1,y1,x2,y2,k; cin >> x1 >> y1 >> x2 >> y2 >> k;
        insert(x1,y1,x2,y2,k);
    }
    
    //求前缀和
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            dis[i][j] = dis[i][j] + dis[i - 1][j] + dis[i][j - 1] - dis[i - 1][j - 1];
            cout << dis[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}